import Vue from 'vue'
import Router from 'vue-router'


Vue.use(Router)
/* Layout */
import Layout from '../views/layout/Layout'

//导出默认对象Router，只有导出之后才能被使用
export default new Router({
  routes: [
    {
      //路由路径 相当于@RequestMapping
      path: '/login',
      //路由名称
      name: 'login',
      //跳转的组件的路径
      component: (resolve) => require(['../views/login/login'], resolve),
    },
    {
      path: '/',
      component: Layout,
      redirect: '/home',
      name: 'homepage',
      children: [{
        path: 'home',
        component: () => import('@/views/homepage/homepage'),
        name: 'homepage',
        meta: { title: '首页', icon: 'dashboard', noCache: true }
      }]
    },
    {
      path: '/tool',
      component: Layout,
      redirect: '/tool/dictionary',
      name: 'tool',
      meta: { title: '系统管理', icon: 'user' },
      children: [
        {
          path: 'dictionary',
          component: () => import('@/views/tool/dictionary'),
          name: 'dictionary',
          meta: { title: '字典管理', icon: 'list'}
        },
        {
          path: 'loginLog',
          component: () => import('@/views/tool/loginLog'),
          name: 'log',
          meta: { title: '登录日志', icon: 'list'}
        },
        {
          path: 'MTool',
          component: () => import('@/views/tool/manager'),
          name: 'MT',
          meta: { title: '管理员工具', icon: 'list'}
        },
      ]
    },
    {
      path: '/user',
      component: Layout,
      redirect: '/user/list',
      name: 'user',
      meta: { title: '用户管理', icon: 'user' },
      children: [
        {
          path: 'list',
          component: () => import('@/views/user/userList'),
          name: 'list',
          meta: { title: '用户列表', icon: 'list'}
        },
      ],
    },
    {
      path: '/borrow',
      component: Layout,
      redirect: '/borrow/list',
      name: 'borrow',
      meta: { title: '借阅管理', icon: 'list' },
      children: [
        {
          path: 'list',
          component: () => import('@/views/borrow/borrow'),
          name: 'borrowList',
          meta: { title: '借阅列表', icon: 'list'}
        },
        {
          path: 'borrowing',
          component: () => import('@/views/borrow/borrowing'),
          name: 'borrowing',
          meta: { title: '未处理订单', icon: 'list'}
        },
      ],
    },
    {
      path: '/book',
      component: Layout,
      redirect: '/book/list',
      name: 'book',
      meta: { title: '图书管理', icon: 'list' },
      children: [
        {
          path: 'list',
          component: () => import('@/views/book/bookList'),
          name: 'bookList',
          meta: { title: '图书列表', icon: 'list'}
        },
        {
          path: 'hotBook',
          component: () => import('@/views/book/bookHot'),
          name: 'hotBook',
          meta: { title: '热门图书管理', icon: 'list'}
        },
      ],
    },

  ]
})
